Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I don't know if this is something you're interested in, but it's the direction in which I plan to take my personal fork of ldtk-haxe-api
The Problem
I find it oddly hard to write generic code for ldtk, that is useful in multiple projects or for multiple types that are built via macros. The use of macros are - I'll admit - a fucking lifesaver and make starting new projects a breeze, but I find myself copying and pasting the same utilizing code from project to project (and sometimes multiple times in the same project) and changing the class names just to get the same fields that are in every tileset or tile layer but not in the respective base classes
The Solution
Put those fields and functions in the base classes and use type params to make it easy to pass them around to generic utils without needing to know the specific generated class for each project.
The Changes
Tileset
toTypedTileset<TTag:EnumValue>
, and add a untypedTileset
typedefhasTag
andgetAllTags
to the base class, overridegetAllTags
in the built types, (I could also make Tileset an abstract class, but that seemed more risky, as it's a recent haxe feature, and maybe not a backward compatible change)Layer_Tiles
toTypedLayer_Tiles<TTag:EnumValue>
and add a untypedLayer_Tiles
typedef. In my tools I'm using this for `@:privateAccess layer.untypedTilesettileset
field toLayer_Tiles
Another option, rather than having the old type as a typedef of the new typed class, we could have the typed class extend the untyped version with the newly added typed fields (just thought of this, might explore as it may resolve some covariance issues)
The future
I think there many other places that would benefit from having more generic type options, I can make an issue listing them out if there's any interest